import { getFormatterPrice, formatDate } from '@const/filter'

// 业务模式（100：批发业务 101：长期寄售 104：商务通）
// 订单类型（WHOLESALE_ISSUE：批发业务-普通订单 LCONSIGN_ISSUE：长期寄售-销售确认 ECO_NORMAL：商务通-正常订单）
export const OMS_BUSITYPE_OPTIONS = [
  { label: '批发业务',
    value: '100',
    children: [
      { label: '批发业务-普通订单', value: 'WHOLESALE_ISSUE' }
    ]
  },
  { label: '长期寄售',
    value: '101',
    children: [
      { label: '长期寄售-销售确认', value: 'LCONSIGN_ISSUE' }
    ]
  },
  { label: '商务通',
    value: '104',
    children: [
      { label: '商务通-正常订单', value: 'ECO_NORMAL' }
    ]
  }
]
export const OMS_BUSITYPE = {
  '100': '批发业务',
  '101': '长期寄售',
  '104': '商务通'
}
export const ORDER_TYPE_OPTIONS = []
export const ORDER_TYPE = {
  'WHOLESALE_ISSUE': '批发业务-普通订单',
  'LCONSIGN_ISSUE': '长期寄售-销售确认',
  'ECO_NORMAL': '商务通-正常订单'
}
// 后结算订单状态
// 开票订单状态（1-待开票；2-已推送；3-已开票；4-验票完成；5-已撤销）
export const statusArr = {
  0: '全部',
  1: '待开票',
  2: '已推送',
  3: '已开票',
  4: '验票完成',
  5: '已撤销'
}

// 列表--搜索字段
export const indexSearchData = [
  {
    key: 'invoiceCode',
    title: '销售单号',
    type: 'input',
    attr: {
      placeholder: '请输入'
    }
  },
  {
    key: 'relationCode',
    title: '关联订单号',
    type: 'input',
    attr: {
      placeholder: '请输入'
    }
  },
  {
    key: 'settleStartTime',
    title: '结算日期',
    type: 'time',
    fieldname: ['settleBeginDate', 'settleEndDate'],
    attr: {
      style: 'width:270px !important;',
      class: 'daterange',
      type: 'daterange',
      'start-placeholder': '开始时间',
      'end-placeholder': '结束时间',
      'default-time': ['00:00:00', '23:59:59']
    }
  },
  {
    key: 'hospitalName',
    title: '医疗机构',
    type: 'input',
    attr: {
      placeholder: '请输入'
    }
  },
  {
    key: 'supplierName',
    title: '供应商',
    type: 'input',
    attr: {
      placeholder: '请输入'
    }
  },
  {
    key: 'applyDept',
    title: '申请科室',
    type: 'input',
    attr: {
      placeholder: '请输入'
    }
  },
  {
    key: 'startTime',
    title: '创建时间',
    type: 'time',
    fieldname: ['createAtBegin', 'createAtEnd'],
    attr: {
      style: 'width:270px !important;',
      class: 'daterange',
      type: 'daterange',
      'start-placeholder': '开始时间',
      'end-placeholder': '结束时间',
      'default-time': ['00:00:00', '23:59:59']
    }
  }
  // {
  //   key: 'productName',
  //   title: '产品名称',
  //   type: 'input',
  //   attr: {
  //     placeholder: '请输入'
  //   }
  // }
]
// 开票管理 -操作页搜索
export const invoiceSearchData = [
  {
    key: 'hosProdCode',
    title: '产品编码',
    type: 'input',
    attr: {
      placeholder: '请输入'
    }
  },
  {
    key: 'hosProdName',
    title: '产品名称',
    type: 'input',
    attr: {
      placeholder: '请输入'
    }
  },
  {
    key: 'hosProdSpec',
    title: '规格',
    type: 'input',
    attr: {
      placeholder: '请输入'
    }
  },
  {
    key: 'hosRegistNo',
    title: '注册证/备案证号',
    type: 'input',
    attr: {
      placeholder: '请输入'
    }
  },
  {
    key: 'hosProdManufacturer',
    title: '生产厂家',
    type: 'input',
    attr: {
      placeholder: '请输入'
    }
  }
]
// 列表--列表表头
export const indexTableData = [
  // { width: '40', fixed: 'left', type: 'selection' },
  { prop: 'invoiceCode', label: '销售单号', width: 170, 'show-overflow-tooltip': true },
  { prop: 'relationCode', label: '关联订单号', width: 170, 'show-overflow-tooltip': true },
  { prop: 'settleDate', label: '结算日期', width: 120 },
  { prop: 'applyDept', label: '申请科室', width: 170 },
  { prop: 'prodVarietyCount', label: '品种数', width: 100 },
  { prop: 'prodTotalCount', label: '产品数量', width: 150 },
  { prop: 'orderTotalAmount', label: '订单金额 （元）', width: 150, formatter: row => getFormatterPrice(row.orderTotalAmount) },
  { prop: 'receiveAddress', label: '收货地址', width: 150, 'show-overflow-tooltip': true },
  { prop: 'contacts', label: '联系人', width: 150 },
  { prop: 'contactNumber', label: '联系电话', width: 130 },
  { prop: 'hospitalName', label: '医疗机构', 'min-width': 170, 'show-overflow-tooltip': true },
  { prop: 'supplierName', label: '供应商', 'min-width': 170, 'show-overflow-tooltip': true },
  { prop: 'createdAt', label: '创建时间', width: 160 },
  { prop: 'orderStatus',
    label: '订单状态',
    width: 100,
    formatter: row => {
      return statusArr[row.orderStatus]
    } },
  { prop: 'action', label: '操作', width: 100, fixed: 'right' }
]

// 列表页-tab
// 开票订单状态（1-待开票；2-已推送；3-已开票；4-验票完成；5-已撤销）
export const indexTabsArr = [
  { lab: '待开票', val: 1, badge: { value: null } },
  { lab: '已推送', val: 2, badge: { value: null } },
  { lab: '已开票', val: 3, badge: { value: null } },
  { lab: '验票完成', val: 4, badge: { value: null } },
  { lab: '已撤销', val: 5, badge: { value: null } },
  { lab: '全部', val: 0, badge: { value: null } }
]
// 产品大类
export const categoryArr = {
  1: '高值',
  2: '低值',
  3: '试剂',
  4: '设备',
  5: '器械'
}
// 详情 - 表格
export const invoiceTableColumns = [
  { prop: 'busiType',
    label: '业务模式',
    width: 150,
    'show-overflow-tooltip': true,
    formatter: row => {
      return OMS_BUSITYPE[row.busiType]
    }
  },
  { prop: 'orderType',
    label: '订单类型',
    width: 150,
    'show-overflow-tooltip': true,
    formatter: row => {
      return ORDER_TYPE[row.orderType]
    }
  },
  // formatDate(formdata[item.key][0], 'YYYY-MM-DD HH:mm:ss')
  { prop: 'invoiceUrl', label: '发票影像', width: 100 },
  { prop: 'invoiceDetails', label: '发票详情', width: 100 },
  { prop: 'invoiceNo', label: '发票号', width: 150, 'show-overflow-tooltip': true },
  { prop: 'num', label: '发货数量', width: 150, 'show-overflow-tooltip': true },
  { prop: 'productDate', label: '生产日期', width: 150, 'show-overflow-tooltip': true, formatter: row => formatDate(row.productDate, 'YYYY-MM-DD') },
  { prop: 'expDate', label: '失效日期', width: 150, 'show-overflow-tooltip': true, formatter: row => formatDate(row.expDate, 'YYYY-MM-DD') },
  { prop: 'productBatch', label: '批号', width: 150, 'show-overflow-tooltip': true },
  { prop: 'serialNo', label: '序列号', width: 150, 'show-overflow-tooltip': true },
  { prop: 'udi', label: 'UDI', width: 150, 'show-overflow-tooltip': true },
  { prop: 'orderItemCode', label: '销售明细单号', width: 150, 'show-overflow-tooltip': true },
  { prop: 'relationItemCode', label: '关联明细单号', width: 150, 'show-overflow-tooltip': true },
  { prop: 'pssProdCode', label: '产品编码', width: 150 },
  { prop: 'pssProdName', label: '产品名称', width: 150, 'show-overflow-tooltip': true },
  { prop: 'pssProdSpec', label: '规格', width: 150, 'show-overflow-tooltip': true },
  { prop: 'pssProdModel', label: '型号', width: 150 },
  { prop: 'pssMinUnit', label: '最小单位', width: 150 },
  { prop: 'prodSalePrice', label: '销售价格 （元）', width: 150, formatter: row => getFormatterPrice(row.prodSalePrice) },
  { prop: 'pssRegistNo', label: '注册证号/备案证号', width: 170, 'show-overflow-tooltip': true },
  { prop: 'pssProdManufacturer', label: '生产厂家', width: 150, 'show-overflow-tooltip': true },
  { prop: 'pssBigCategory',
    label: '产品大类',
    width: 90,
    formatter: row => {
      return categoryArr[row.pssBigCategory] || categoryArr[row.pssHighLow]
    }
  },
  { prop: 'prodCount', label: '销售数量', width: 150 },
  { prop: 'detailAmount', label: '销售金额 （元）', width: 150, formatter: row => getFormatterPrice(row.detailAmount) },
  { prop: 'hosProdCode', label: '医院产品编码', width: 150, 'show-overflow-tooltip': true },
  { prop: 'hosProdName', label: '医院产品名称', width: 150, 'show-overflow-tooltip': true },
  { prop: 'hosProdSpec', label: '医院产品规格', width: 150, 'show-overflow-tooltip': true },
  { prop: 'hosProdModel', label: '医院产品型号', width: 150, 'show-overflow-tooltip': true },
  { prop: 'hosMinUnit', label: '最小单位', width: 150 },
  { prop: 'hosRegistNo', label: '注册证号/备案证号', width: 170, 'show-overflow-tooltip': true },
  { prop: 'hosProdManufacturer', label: '生产厂家', width: 150, 'show-overflow-tooltip': true }
]
// 推送 - 表格
export const invoicePushColomns = [
  { width: '40', fixed: 'left', type: 'selection' },
  ...(invoiceTableColumns.slice(0, 2)),
  ...(invoiceTableColumns.slice(5, 22)),
  { prop: 'prodCount', label: '发货数量', width: 150 },
  { prop: 'detailAmount', label: '小计金额 （元）', width: 150, formatter: row => getFormatterPrice(row.detailAmount) },
  ...(invoiceTableColumns.slice(24))
]
// 开票 - 表格
export const invoiceFinanceColomns = [
  { width: '40', fixed: 'left', type: 'selection' },
  { prop: 'mplatInvoiceStatus', label: '发票详情', width: 100 },
  { prop: 'invoiceNo', label: '发票号', width: 150, 'show-overflow-tooltip': true },
  { prop: 'invoiceUrl', label: '发票影像', width: 100 },
  ...(invoiceTableColumns.slice(5, 22)),
  { prop: 'prodCount', label: '发货数量', width: 150 },
  { prop: 'detailAmount', label: '小计金额 （元）', width: 150, formatter: row => getFormatterPrice(row.detailAmount) },
  ...(invoiceTableColumns.slice(24))
]
// 推送页-基本信息表头
export const recordFormDetail = [
  [
    { key: 'invoiceCode', label: '销售单号' },
    { key: 'relationCode', label: '关联订单号' },
    { key: 'orderStatus', label: '状态' }],
  [{ key: 'createdAt', label: '创建时间' },
    { key: 'hospitalName', label: '医疗机构' },

    { key: 'supplierName', label: ' 供应商' }],
  [
    { key: 'applyDept', label: '申请科室' },
    { key: 'receiveAddress', label: '收货地址' },
    { key: 'contacts', label: '联系人' }
  ],
  [
    { key: 'contactNumber', label: '联系电话' }
  ]
]
// 详情页-基本信息表头
export const invoiceCommonForm = [
  [
    { key: 'invoiceCode', label: '销售单号' },
    { key: 'orderStatus', label: '状态' },
    { key: 'createdAt', label: '创建时间' }
  ],
  [
    { key: 'hospitalName', label: '医疗机构' },
    { key: 'supplierName', label: '供应商' },
    { key: 'settleDate', label: '结算日期' }
  ],
  [
    { key: 'applyDept', label: '申请科室' },
    { key: 'receiveAddress', label: '收货地址' },
    { key: 'contacts', label: '联系人' }
  ],
  [
    { key: 'contactNumber', label: '联系电话' }
  ]
]
